import {
  Controller,
  Inject,
  Get,
  Query,
  Body,
  Post,
  Param,
  Del,
} from '@midwayjs/core';
import { SectService } from '@service/jx3/sect.service';
import { ListSectDTO } from '@dto/jx3/sect.dto';
import { BusinessType, Log } from '@decorator/log.decorator';

@Controller('/jx3/sect')
export class PostController {
  @Inject()
  SectService: SectService;

  // 获取列表
  @Get('/list')
  async list(@Query() queryParams: ListSectDTO) {
    return await this.SectService.list(queryParams);
  }

  // 新增
  @Log({ title: '门派新增', businessType: BusinessType.ADD })
  @Post('/add')
  async create(@Body() Sect: any) {
    return await this.SectService.create(Sect);
  }

  // 删除
  @Log({ title: '门派删除', businessType: BusinessType.REMOVE })
  @Del('/:SectId')
  async delete(@Param('SectId') SectId: string) {
    return await this.SectService.delete(SectId);
  }

  // 修改
  @Log({ title: '门派修改', businessType: BusinessType.EDIT })
  @Post('/update')
  async update(@Body() Sect: any) {
    return await this.SectService.update(Sect);
  }

  // 获取门派详情
  @Get('/:SectId')
  async get(@Param('SectId') SectId: string) {
    return await this.SectService.detail(SectId);
  }
}
